<!--
报告管理-报告管理
 add by yyp 2020-01-12
 update 2020-02-04
-->
<template lang="pug">
  keep-alive
    kalix-table(bizKey="Report" title='报告管理' ref="kalixTable"
    v-bind:tableFields="tableFields"
    v-bind:targetURL="ReportURL"
    v-bind:bizDialog="reportDialog"
    v-bind:btnList="reportBtnList"
    v-bind:toolbarBtnList="toolbarBtnList"
    v-bind:customRender="showChapter"
    bizSearch="reportSearch")
      template(slot="tableColumnSlot")
        el-table-column(prop="name" label="患者姓名" align="center")
        el-table-column(prop="hospitalName" label="原切片单位" align="center")
        el-table-column(prop="className" label="档案分类" align="center")
        el-table-column(prop="pathologyNum" label="病历号" align="center")
        el-table-column(prop="doctor" label="申请医师" align="center")
        el-table-column(prop="diagnosis" label="临床诊断" align="center")
        el-table-column(prop="diagnosisDetail" label="详细临床诊断" align="center")
          template(slot-scope="scope")
            span {{scope.row.diagnosisDetail | ellipsis}}
        el-table-column(prop="status" label="打印状态" align="center")
        el-table-column(prop="applicationTime" label="申请时间" align="center")
          template(slot-scope="scope")
            span {{dataFormat(scope.row.applicationTime)}}
        el-table-column(prop="hospitalNameExpert" label="会诊医院" align="center")
        el-table-column(prop="expert" label="会诊专家" align="center")
        el-table-column(prop="date" label="会诊日期" align="center")
          template(slot-scope="scope")
            span {{dataFormat(scope.row.date)}}
        el-table-column(prop="number" label="会诊号" align="center")
        el-table-column(prop="picture" label="光镜所见" align="center")
            template(slot-scope="scope")
                img(v-if="scope.row.picture" v-bind:src="scope.row.picture" width="52" height="52" alt="")
        el-table-column(prop="opinion" label="会诊意见" align="center")
        el-table-column(prop="downloadFlag" label="是否下载" align="center")
          template(slot-scope="scope")
            span {{scope.row.downloadFlag === true ? '是' : '否'}}
        el-table-column(prop="videoName" label="录播视频" align="center")
        <!--el-table-column(prop="statusOn" label="申请修改报告" align="center")-->
</template>

<script type="text/ecmascript-6">
  import {ReportURL, ClassURL, HospitalURL, FileURL} from '../../config.toml'
  import {reportConfigBtnList} from './config'
  import KalixTable from '../../../../../components/corelib/components/common/baseTable'

  export default {
    filters: {
      ellipsis (value) {
        if (!value) return ''
        if (value.length > 8) {
          return value.slice(0, 8) + '...'
        }
        return value
      }
    },
    name: 'kalix-telemedicine-reports',
    components: {KalixTable},
    data() {
      return {
        ReportURL: ReportURL,
        tableFields: [
          // {prop: 'name', label: '患者姓名'},
          // // {prop: 'age', label: '患者年龄'},
          // // {prop: 'sex', label: '患者性别'},
          // // {prop: 'idCard', label: '患者身份证号'},
          // {prop: 'unitZ', label: '原切片单位'},
          // // {prop: 'cid', label: '档案分类id'},
          // {prop: 'cname', label: '档案分类'},
          // {prop: 'pathologyNum', label: '病历号'},
          // {prop: 'diagnosis', label: '临床诊断'},
          // {prop: 'diagnosisDetail', label: '详细临床诊断'},
          // {prop: 'status', label: '打印状态'},
          // {prop: 'applicationTime', label: '申请时间'},
          // // {prop: 'fid', label: '关联档案管理id'},
          // {prop: 'expert', label: '会诊专家'},
          // {prop: 'date', label: '会诊日期'},
          // {prop: 'number', label: '会诊号'},
          // {prop: 'pictureZ', label: '光镜所见'},
          // {prop: 'opinion', label: '会诊意见'},
          // {prop: 'statusOn', label: '申请修改报告'}
        ],
        reportDialog: [
          {id: 'view', dialog: 'reportView'},
          {id: 'edit', dialog: 'reportEdit'}
        ],
        reportBtnList: reportConfigBtnList,
        toolbarBtnList: [
          {id: 'add', isShow: false, title: '添加', icon: 'icon-pinleizengjia', isPermission: false}
        ]
      }
    },
    mounted() {
      this.getClassType()
      this.getHospital()
      this.getFile()
    },
    methods: {
      getClassType() {
        this.axios.request({
          method: 'GET',
          url: ClassURL
        }).then(res => {
          this.claName = res.data.data
        })
      },
      getHospital() {
        this.axios.request({
          method: 'GET',
          url: HospitalURL
        }).then(res => {
          this.HoName = res.data.data
        })
      },
      getFile() {
        this.axios.request({
          method: 'GET',
          url: FileURL
        }).then(res => {
          this.fileData = res.data.data
        })
      },
      dataFormat(val) {
        let d = new Date(val)
        return this.$M_FormatDate(d, 'yyyy-MM-dd hh:mm:ss')
      },
      showChapter(_data) {
        if (_data) {
          _data.forEach((e) => {
            if (e.videoUrl != null) {
              // 视频文件路径
              e.videoName = e.videoUrl
              let str0 = e.videoName
              e.videoName = str0.substring(str0.lastIndexOf('/') + 1, str0.length)
            }
            if (e.picture != null) {
              e.pictureZ = e.picture
              let str = e.pictureZ
              e.pictureZ = str.substring(str.lastIndexOf('/') + 1, str.length)
            }
          })
        }
        // setTimeout(() => {
        // let data = this.$refs.kalixTable.tableData
        // // 会诊医院
        // for (let i = 0; i < data.length; i++) {
        //   for (let j = 0; j < this.fileData.length; j++) {
        //     if (data[i].fid === this.fileData[j].id) {
        //       this.$refs.kalixTable.tableData[i].nameZ = this.fileData[j].name
        //       this.$refs.kalixTable.tableData[i].pathologyNumZ = this.fileData[j].pathologyNum
        //       this.$refs.kalixTable.tableData[i].doctorZ = this.fileData[j].doctor
        //       this.$refs.kalixTable.tableData[i].diagnosisZ = this.fileData[j].diagnosis
        //       this.$refs.kalixTable.tableData[i].diagnosisDetailZ = this.fileData[j].diagnosisDetail
        //       this.$refs.kalixTable.tableData[i].statusZ = this.fileData[j].status
        //       this.$refs.kalixTable.tableData[i].applicationTimeZ = this.fileData[j].applicationTime
        //       this.$refs.kalixTable.tableData[i].unitZ = this.fileData[j].unit
        //       this.$refs.kalixTable.tableData[i].cnameZ = this.fileData[j].cid
        //       this.$refs.kalixTable.tableData[i].ageZ = this.fileData[j].age
        //       this.$refs.kalixTable.tableData[i].sexZ = this.fileData[j].sex
        //     }
        //   }
        // }
        // for (let i = 0; i < data.length; i++) {
        //   for (let j = 0; j < this.HoName.length; j++) {
        //     if (data[i].hospital === this.HoName[j].id) {
        //       this.$refs.kalixTable.tableData[i].hospitalZ = this.HoName[j].hospitalName
        //     }
        //     if (data[i].unitZ === this.HoName[j].id) {
        //       this.$refs.kalixTable.tableData[i].unitZ = this.HoName[j].hospitalName
        //     }
        //   }
        // }
        // for (let i = 0; i < data.length; i++) {
        //   for (let j = 0; j < this.claName.length; j++) {
        //     if (data[i].fid === this.claName[j].id) {
        //       this.$refs.kalixTable.tableData[i].cnameZ = this.claName[j].className
        //     }
        //   }
        // }
        // }, 1000)
      }
    }
  }
</script>

<style scoped lang="stylus">

</style>
